package datacontainers;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;

public class Menu {

    protected HashMap<Category, List<Dish>> categories = new HashMap<Category, List<Dish>>();

    private Date actualDate;

    public void setActualDate(Date date) {
	actualDate = date;
    }

    public Date getActualDate() {
	return actualDate;
    }

    /**
     * add dish if not exist
     * 
     * @param dish
     */
    public void addDish(Dish dish) {
	List<Dish> items = categories.get(dish.getCategory());
	if (items == null) {
	    categories.put(dish.getCategory(), new ArrayList<Dish>());
	    items = categories.get(dish.getCategory());
	}
	if ((items.indexOf(dish) == -1)) {
	    items.add(dish);
	}
    }

    public List<Dish> getCategory(Category cat) {
	if (categories.get(cat) == null) {
	    categories.put(cat, new ArrayList<Dish>());
	}
	return categories.get(cat);
    }

    public void deleteDish(Dish dish) {
	getCategory(dish.getCategory()).remove(dish);
    }

}
